package com.yanghang.controller;

import com.github.pagehelper.PageInfo;
import com.yanghang.entity.News;
import com.yanghang.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class NewsController {
    @Autowired
    private NewsService ns;
    @GetMapping("/news")
   public List<News>selectAll(){
        return ns.selectAllNews();
    }
    @GetMapping("/new")
    public PageInfo<News>selectByPage(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "3") int pageSize){
       return ns.selectByPage(pageNum, pageSize);
    }
}
